package com.test.jni.service;

import com.test.jni.model.Param;
import com.test.jni.model.ReturnParam;
import lombok.extern.slf4j.Slf4j;

/**
 * Jni调用服务
 */
@Slf4j
public class CallJniService {

    /**
     * 声明Native Method，对应hello的方法
     * 对象传参，返回码对象结果
     */
    public static native ReturnParam hello(Param param);

    public static void callJniMethod() {
        // 调用 add方法，完成计算
        Param param = new Param(6, 8, "add");
        log.info("param={}", param.toString());

        // 调用 hello方法
        ReturnParam hello = hello(param);
        log.info("add msg(hello.msg)={}", hello.getMsg());
        log.info("add result(hello.c)=={}", hello.getC());
    }

}